package com.strategy
{
	import com.utils.FileWriter;
	
	import mx.controls.Alert;

	public class BMLContext
	{
		private var _myBMLStrategy:IBML;
		public function BMLContext()
		{
			
		}
		/**
		 *动态决定策略类型 
		 * @param strategy	具体的策略
		 * 
		 */			
		public function dynamicDecide(strategy:IBML):void
		{
			_myBMLStrategy = strategy;
		}
		
		/**
		 *执行具体策略 
		 * 
		 */		
		public function specificStrategy():void
		{
			if(!_myBMLStrategy){
				throw new Error("请保证先决定一个策略");
			}
			
			var saveXML:XML = _myBMLStrategy.bmlstrategyxml();
			if(saveXML==null){
				Alert.show("请确保选择了正确的数据类型结构");
				return;
			}
			FileWriter.getInstance().saveXML(saveXML);
			
		}
	}
}